home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / FROMUTS / UNIXLIB37B / src / unix / c / chmod < prev    next >
Text File  |  1991-06-14  |  588b  |  40 lines

  1. static char sccs_id[] = "@(#) chmod.c 1.2 "__DATE__" HJR";
  2.  
  3. /* chmod.c (c) Copyright 1990 H.Rogers */
  4.  
  5. #include <errno.h>
  6.  
  7. #include "sys/types.h"
  8. #include "sys/unix.h"
  9. #include "sys/os.h"
  10.  
  11. int chmod(char *file,register int mode)
  12. {
  13. int r[6];
  14. os_error *e;
  15.  
  16. file = __uname(file,0);
  17.  
  18. if (e = os_file(5,file,r))
  19.   {
  20.   __seterr(e);
  21.   return(-1);
  22.   }
  23. if (!r[0])
  24.   {
  25.   errno = ENOENT;
  26.   return(-1);
  27.   }
  28.  
  29. r[5] = (r[5] & 0xFFFFFF00) | ((mode & 0400)>>8) | ((mode & 0200)>>6) |
  30.     ((mode & 0004)<<2) | ((mode & 0002)<<4);
  31.  
  32. if (e = os_file(1,file,r))
  33.   {
  34.   __seterr(e);
  35.   return(-1);
  36.   }
  37.  
  38. return(0);
  39. }
  40.